﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GeneratorLib.DB;
using GeneratorLib.DB.Connectios;
using GeneratorLib.DB.Schemas;

namespace DBExplorer
{
    public partial class FrmTableAddinEdit : Form
    {
        public FrmTableAddinEdit()
        {
            InitializeComponent();
        }

        private TableInfoAddin _tableAddin;
        public TableInfoAddin TableAddin
        {
            get
            {
                return _tableAddin;
            }
            set
            {
                _tableAddin = value;
                txtDisplayName.Text = value.TableDisplayName;
                txtFields.Clear();
                foreach (var addin in value.FieldAddins)
                {
                    txtFields.AppendText(string.Format("{0}={1}{2}", addin.FieldName, addin.DisplayName, Environment.NewLine));
                }

            }
        }

        private void btOK_Click(object sender, EventArgs e)
        {
            _tableAddin.TableDisplayName = txtDisplayName.Text.Trim();
            _tableAddin.SetFieldAddins(txtFields.Text);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

    }
}
